#include<iostream>
#include<vector>
#include<string.h>
using namespace std;
int n{0}, tmp{0}, a[103];
vector<int> v;
int dp(int i, int loc);


int main()
{
    int n1{0}, n2{0};
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> tmp;
        v.push_back(tmp);
    }
    // v.push_back(v[0]);
    // n++;
    if(n == 0) cout << 0 << endl;
    else if(n == 1) cout << v[0] << endl;
    else if(n == 2) cout << max(v[0],v[1]) << endl;  // 特殊情况不能忘记讨论
    else
    {
        memset(a, 0, sizeof(a));
        n1 = dp(0, n-1);
        memset(a, 0, sizeof(a));  // 这里要再进行初始化
        n2 = dp(1, n);
        cout << max(n1, n2);
    }
    return 0;
}


int dp(int i, int loc) // 位置很重要
{
    if (i >= loc) return 0;
    if(a[i]) return a[i];  // 记忆数据！
    a[i+1] = dp(i+1, loc);
    a[i+2] = dp(i+2, loc);
    int money1{0}, money2{0};
    money1 = v[i] + a[i+2];
    money2 = a[i+1];
    
    if (money1 > money2)  return money1;
    else return money2;
}